package com.sangeng.controller;


import com.sangeng.annotation.SystemLog;
import com.sangeng.domain.ResponseResult;
import com.sangeng.domain.dto.LinkDto;
import com.sangeng.domain.entity.Link;
import com.sangeng.service.LinkService;
import com.sangeng.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 友链(Link)表控制层
 *
 * @author makejava
 * @since 2024-08-27 17:42:24
 */
@RestController
@RequestMapping("/content/link")
public class LinkController {
    /**
     * 服务对象
     */
    @Autowired
    private LinkService linkService;

    @SystemLog(businessName = "友链的分页查询接口")
    @GetMapping("/list")
    public ResponseResult getPageLinkList(Long pageNum,Long pageSize,String name,String status){
       return linkService.getPageLinkList(pageNum,pageSize,name,status);
    }

    @SystemLog(businessName = "新增友链接口")
    @PostMapping
    public ResponseResult addLink(@RequestBody LinkDto linkDto){
        return linkService.addLink(linkDto);
    }

    @SystemLog(businessName = "根据id查询友联")
    @GetMapping("/{id}")
    public ResponseResult getLinkById(@PathVariable Long id){
        return linkService.getLinkById(id);
    }

    @SystemLog(businessName = "修改友链接口")
    @PutMapping
    public ResponseResult updateLink(@RequestBody LinkDto linkDto ){
        return linkService.updateLink(linkDto);
    }

    @SystemLog(businessName = "删除友链")
    @DeleteMapping("/{id}")
    public ResponseResult deleteLinkById(@PathVariable Long id){
        return linkService.deleteLinkById(id);
    }

    @SystemLog(businessName = "修改友链的状态")
    @PutMapping("/changeStatus")
    public ResponseResult changeStatus(@RequestBody LinkDto linkDto){
       return linkService.changeStatus(linkDto);
    }
}

